package cn.itrip.biz.controller;

import cn.itrip.beans.dto.Dto;
import cn.itrip.beans.pojo.ItripUser;
import cn.itrip.beans.pojo.ItripUserLinkUser;
import cn.itrip.biz.service.HotelOrderService;
import cn.itrip.biz.service.UserLinkUserService;
import cn.itrip.utlis.DtoUtil;
import cn.itrip.utlis.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Description :
 * Created by Li on 2020-12-30 11:43:28
 */
@RestController
@RequestMapping("/api/userinfo")
public class UserInfoController {
    @Autowired
    private TokenUtil tokenUtil;
    @Autowired
    private UserLinkUserService linkUserService;

    @PostMapping("/queryuserlinkuser")
    public Dto queryuserlinkuser(HttpServletRequest request){
        String token = request.getHeader("token");
        ItripUser user = tokenUtil.getUser(token);
        if(user == null) {
            return DtoUtil.returnFail("请先登录","100001");
        }
        List<ItripUserLinkUser> list =  linkUserService.queryuserlinkuser(user.getId());
        return DtoUtil.returnDataSuccess(list);
    }
}
